//
// Created by DengLibin on 2018/12/11 0011.
//
#include <iostream>
using namespace std;
/**
 * 对象
 */
 class Person
 {
 public:
     int age = 0;
     Person(int age)
     {
         this->age = age;
     }

     Person(const Person & person)
     {
         this->age = person.age;
         cout <<"拷贝构造函数"<<endl;
     }
     ~Person()
     {
        cout <<"析构函数"<<endl;
     }
     void show()
     {
         cout << "age = "<<this->age<<endl;
     }
 };

 //对象数组(栈)
 void object_arr()
 {
     Person persons[3] = {Person(1), Person(2),Person(3)};//数组
     Person p = persons[0]; //拷贝构造函数
 }
 //对象指针数组（堆）
 void object_arr2()
 {
    Person * arr[3] = {new Person(1),new Person(2),new Person(3)};

    for(int i = 0; i < 3; i++)
    {
        delete arr[i];
    }
 }
 int main3()
 {
    object_arr2();
    return 0;
 }


